home *** CD-ROM | disk | FTP | other *** search
- // LF2 Engine
- // (C) 2002-3 7FX
- //---------------------------------------------------------------------------
- #include "common.fxh"
- //---------------------------------------------------------------------------
- // Common parameters
- // Desc
- string desc : Description = "Mapuje difuzni texturu na mesh.";
- // Requirements
- string req : Requirements = "Diffusemap";
- // vertex format
- string vf : VertexFormat = "POSITION | DIFFUSEMAP"; // 65 (for export)
- //---------------------------------------------------------------------------
- // Used constants
- const matrix cMtxWVP : WorldViewProjection;
- const int cAlphaRef : AlphaRef = 0;
- // Diffuse color, default white
- const float4 cDiffuse : Diffuse = {1.f, 1.f, 1.f, 1.f};
- // CullMode - NONE=1, CW=2, CCW=3
- const int cCullMode : CullMode = 3; // default CCW
- // Matrices for fixed function technique
- const matrix cMtxW : World;
- // Sampler filters
- DECLARE_TEX_SAMPLER_VALUES;
- //---------------------------------------------------------------------------
- // Diffuse map effect
- texture2D diffusemap : DiffuseMap;
- //---------------------------------------------------------------------------
- // Diffuse map sampler
- sampler diffusemap_sampler = sampler_state
- {
- Texture = <diffusemap>;
- SET_TEX_SAMPLER_VALUES;
- };
- //---------------------------------------------------------------------------
- // programs
- struct VS_OUTPUT
- {
- float4 Position : POSITION;
- float2 DiffuseMapCoord : TEXCOORD0;
- };
-
- // vertex shader
- VS_OUTPUT VS(float4 Position : POSITION, float2 DiffuseMapCoord : TEXCOORD0)
- {
- VS_OUTPUT Out = (VS_OUTPUT)0;
- Out.Position = mul(Position, cMtxWVP);
- Out.DiffuseMapCoord = DiffuseMapCoord;
- return Out;
- }
-
- // pixel shader
- float4 PS(VS_OUTPUT In) : COLOR
- {
- return cDiffuse * tex2D(diffusemap_sampler, In.DiffuseMapCoord);
- }
-
- //---------------------------------------------------------------------------
- // Technique with vertex and pixel shader
- technique vs11_ps11
- <
- // streams for technique
- string stream1 = "POSITION | DIFFUSEMAP";
- //string stream2 = "POSITION";
- //string stream3 = "DIFFUSEMAP";
- >
- {
- pass p0
- <
- // stream mapping
- string streammap = "stream1";
- //string streammap = "stream2 | stream3";
- >
- {
- AlphaRef = <cAlphaRef>;
- CullMode = <cCullMode>;
-
- VertexShader = compile vs_1_1 VS();
- PixelShader = compile ps_1_1 PS();
- }
- }
- //---------------------------------------------------------------------------
- // Basic technique - vertex shader, no pixel shader
- technique vs11_ps0
- <
- // streams for technique
- string stream1 = "POSITION | DIFFUSEMAP";
- //string stream2 = "POSITION";
- //string stream3 = "DIFFUSEMAP";
- >
- {
- pass p0
- <
- // stream mapping
- string streammap = "stream1";
- //string streammap = "stream2 | stream3";
- >
- {
- AlphaRef = <cAlphaRef>;
- CullMode = <cCullMode>;
- TextureFactor = <cDiffuse>;
-
- VertexShader = compile vs_1_1 VS();
-
- Sampler[0] = <diffusemap_sampler>;
- ColorOp[0] = Modulate;
- ColorArg1[0] = TFactor;
- ColorArg2[0] = Texture;
- AlphaOp[0] = Modulate;
- AlphaArg1[0] = TFactor;
- AlphaArg2[0] = Texture;
- }
- }
- //---------------------------------------------------------------------------
- // Basic technique - fixed function
- technique vs0_ps0
- <
- // streams for technique
- string stream1 = "POSITION | DIFFUSEMAP";
- //string stream2 = "POSITION";
- //string stream3 = "DIFFUSEMAP";
- >
- {
- pass p0
- <
- // stream mapping
- string streammap = "stream1";
- //string streammap = "stream2 | stream3";
- >
- {
- // matrices
- WorldTransform[0] = <cMtxW>;
-
- AlphaRef = <cAlphaRef>;
- CullMode = <cCullMode>;
- TextureFactor = <cDiffuse>;
-
- Sampler[0] = <diffusemap_sampler>;
- ColorOp[0] = Modulate;
- ColorArg1[0] = TFactor;
- ColorArg2[0] = Texture;
- AlphaOp[0] = Modulate;
- AlphaArg1[0] = TFactor;
- AlphaArg2[0] = Texture;
- }
- }
- //---------------------------------------------------------------------------
-
-
-
-
-